Skip to content

refactor(persistence): Store DateTime as ISO-8601 text in DB to preserve sub-seconds precision#2694

Merged
VelikovPetar merged 2 commits into
masterfrom
feature/FLU-503_store_datetime_as_text_in_db
May 28, 2026
Merged

refactor(persistence): Store DateTime as ISO-8601 text in DB to preserve sub-seconds precision#2694
VelikovPetar merged 2 commits into
masterfrom
feature/FLU-503_store_datetime_as_text_in_db

Conversation

@VelikovPetar
Copy link
Copy Markdown
Contributor

@VelikovPetar VelikovPetar commented May 28, 2026

Submit a pull request

Linear: FLU-503

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

  • Changes how DateTime is stored in DB -> from integer seconds to ISO-8601 Strings to preserve sub-second precision
  • Bumps DB version

Summary by CodeRabbit

  • Bug Fixes

    • Improved date and timestamp precision by preserving millisecond values in local storage.
  • Documentation

    • Updated changelog documenting changes to date storage format.
  • Tests

    • Enhanced date validation tests to verify millisecond precision handling.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9eb6a81a-18ae-472c-93da-74036953add0

📥 Commits

Reviewing files that changed from the base of the PR and between d85ff66 and 4e7b305.

📒 Files selected for processing (4)
  • packages/stream_chat_persistence/CHANGELOG.md
  • packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart
  • packages/stream_chat_persistence/test/src/dao/connection_event_dao_test.dart
  • packages/stream_chat_persistence/test/src/utils/date_matcher.dart

📝 Walkthrough

Walkthrough

This PR migrates the local cache database from storing DateTime as integer seconds to ISO-8601 text format, preserving millisecond precision. The schema version increments to 28, database options enable text-based DateTime storage, test matchers verify millisecond equality, and a new test validates the round-trip behavior.

Changes

DateTime Millisecond Precision Storage

Layer / File(s) Summary
Database schema migration and datetime storage configuration
packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart, packages/stream_chat_persistence/CHANGELOG.md
Schema version incremented to 28 and DriftDatabaseOptions configured with storeDateTimeAsText: true to preserve sub-second precision. Changelog documents the behavioral change from integer seconds to ISO-8601 strings.
Test validation for millisecond precision
packages/stream_chat_persistence/test/src/utils/date_matcher.dart, packages/stream_chat_persistence/test/src/dao/connection_event_dao_test.dart
Date matcher extended to verify DateTime.millisecond equality. New test case confirms updateLastSyncAt stores and retrieves a DateTime with full millisecond precision unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A dancer of moments, precise to the tick,
Milliseconds now stored, quick as a trick!
From seconds to strings, the cache holds true,
ISO-8601 precision, fresh and brand new!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the primary change: storing DateTime as ISO-8601 text to preserve sub-second precision, which is reflected across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/FLU-503_store_datetime_as_text_in_db

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VelikovPetar VelikovPetar marked this pull request as ready for review May 28, 2026 07:34
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.38%. Comparing base (d85ff66) to head (4e7b305).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2694      +/-   ##
==========================================
- Coverage   65.38%   65.38%   -0.01%     
==========================================
  Files         423      423              
  Lines       26664    26665       +1     
==========================================
  Hits        17435    17435              
- Misses       9229     9230       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VelikovPetar VelikovPetar merged commit 7f0804d into master May 28, 2026
22 of 27 checks passed
@VelikovPetar VelikovPetar deleted the feature/FLU-503_store_datetime_as_text_in_db branch May 28, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants